package com.ssy.lingxi.order.handler.validator;

import com.ssy.lingxi.common.constant.order.OrderPaymentParameterEnum;
import com.ssy.lingxi.order.handler.annotation.MemberPaymentParameterCodeAnnotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.stream.Stream;

/**
 * 平台后台 - 商户支付参数配置参数枚举字段校验注解验证类
 * @author 万宁
 * @version 2.0.0
 * @date 2021-11-26
 */
public class MemberPaymentParameterCodeValidator implements ConstraintValidator<MemberPaymentParameterCodeAnnotation, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if(value == null) {
            return false;
        }

        return Stream.of(OrderPaymentParameterEnum.ALIPAY_THREAD_APP_AUTH_TOKEN).anyMatch(v -> v.getCode().equals(value));
    }
}
